#include <stdio.h>

char line[ 101 ][ 101 ];
int n, m;

void dfs( int a, int b )
{
    if ( a != 0 )
    {
        if ( line[ a - 1 ][ b ] == '@' )
        {
            line[ a - 1 ][ b ] = '.';
            dfs( a - 1, b );
        }
        if ( b != 0 )
            if ( line[ a - 1 ][ b - 1 ] == '@' )
            {
                line[ a - 1 ][ b - 1 ] = '.';
                dfs( a - 1, b - 1 );
            }
    }
    if ( a != n - 1 )
    {
        if ( line[ a + 1 ][ b ] == '@' )
        {
            line[ a + 1 ][ b ] = '.';
            dfs( a + 1, b );
        }
        if ( b != m - 1 )
            if ( line[ a + 1 ][ b + 1 ] == '@' )
            {
                line[ a + 1 ][ b + 1 ] = '.';
                dfs( a + 1, b + 1 );
            }
    }
    if ( b != 0 )
    {
        if ( line[ a ][ b - 1 ] == '@' )
        {
            line[ a ][ b - 1 ] = '.';
            dfs( a, b - 1 );
        }
        if ( a != n - 1 )
            if ( line[ a + 1 ][ b - 1 ] == '@' )
            {
                line[ a + 1 ][ b - 1 ] = '.';
                dfs( a + 1, b - 1 );
            }
    }
    if ( b != m - 1 )
    {
        if ( line[ a ][ b + 1 ] == '@' )
        {
            line[ a ][ b + 1 ] = '.';
            dfs( a, b + 1 );
        }
        if ( a != 0 )
            if ( line[ a - 1 ][ b + 1 ] == '@' )
            {
                line[ a - 1 ][ b + 1 ] = '.';
                dfs( a - 1, b + 1 );
            }
    }
}

int main( )
{
    int i, j, count;
    while ( scanf("%d%d", &n, &m) != EOF )
    {
        if ( n == 0 && m == 0 ) break;
        gets( line[ 0 ] );
        count = 0;
        for ( i = 0; i < n; i++ )
            gets( line[ i ] );
        for ( i = 0; i < n; i++ )
        {
            for ( j = 0; j < m; j++ )
                if ( line[ i ][ j ] == '@' )
                {
                    count++;
                    line[ i ][ j ] = '.';
                    dfs( i, j );
                }
        }
        printf("%d\n", count);
    }
    return 0;
}
